﻿package com.winmastergames.gameassets {
	import flash.display.*;
	import com.winmastergames.lolgame.mapDefault;
	import flash.events.Event;
	import com.winmastergames.lolgame.engine;

	public class bullet extends MovieClip {
		public var bulletMoveX:Number = 0;
		public var bulletMoveY:Number = 0;
		public var hitObject:Boolean = false;
		public var alive:Boolean = true;
		var Mstage:MovieClip;

		public function bullet(xLoc:Number, yLoc:Number, stageRef:MovieClip, bulletRot:Number){
			Mstage = stageRef;
			stageRef.addChild(this);
			x = xLoc;
			y = yLoc;
			rotation = bulletRot;
			addEventListener(Event.ENTER_FRAME, loop);
		}

		public function killSelf(){
			if (alive == true){
				Mstage.removeChild(this);
				alive = false;
				x = 0;
				y = 0;
			}
		}

		function loop(e:Event) {
			if (engine.objectsPaused == false)
			{
				var xs = 10 * Math.cos((rotation * Math.PI) / 180);
				var ys = 10 * Math.sin((rotation * Math.PI) / 180);
				x += xs;
				y += ys;
			}
		}
	}
}